﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using CoDbObject;

namespace Colligate.DataSource.DriverTraining
{
     /// <summary>
    /// 便签数据定义
    /// </summary>
    internal class TrainingInfo : BaseLegoModule
    {
        private const string TABLE_APPOINT_INFO = "TrnStudentAppointmentInfo";

        public TrainingInfo(IDataSourceLayer dataLayer)
            : base(new string[] { TABLE_APPOINT_INFO //, "TrnCourseInfo", "TrnCourseSectionInfo"
            }, dataLayer)
        {
        }

        #region 返回Lego模块涉及到的数据名称的结构信息
        /// <summary>
        /// 返回Lego模块涉及到的数据名称的结构信息
        /// </summary>
        /// <param name="strDataName">基础表名称</param>
        /// <returns>表结构信息</returns>
        override public IFieldInfo[] GetStructInfo(string strDataName)
        {
            // 建立IFieldInfo列表
            // CFieldInfo(字段名, 类型, 长度, 索引, 状态, 字段说明, 字段帮助, 显示的格式化字符串, 字段宽度, 关联记录)
            // 类型： text，byte，short，long，single，double，currency，date，logical，memo，binary
            // 索引： 0 无索引，1 重复索引，2 唯一索引，3 关键字段
            // 状态： 0 系统字段，>1显示信息的字段， 2 用于标识记录名称的字段

            IFieldInfo[] tableStructInfo;
            switch (strDataName)
            {
                case "TrnStudentAppointmentInfo":	 // 学员预约培训信息
                    tableStructInfo = new IFieldInfo[16];
                    tableStructInfo[0] = new CFieldInfo("fAppointmentGuid", "text", 36, 2, 0, "学员预约培训信息", "学员预约培训信息", "", 52, 0);
                    tableStructInfo[1] = new CFieldInfo("fStudentGuid", "text", 36, 0, 1, "学员标识", "学员标识", "", 52, 0);
                    tableStructInfo[2] = new CFieldInfo("fStudentName", "text", 10, 0, 1, "学员姓名", "学员姓名", "", 52, 0);
                    tableStructInfo[3] = new CFieldInfo("fStudentID", "text", 8, 0, 1, "学员学号", "学员学号", "", 52, 0);
                    tableStructInfo[4] = new CFieldInfo("fAppointmentDate", "date", 0, 0, 1, "预约日期", "预约日期", "", 52, 0);
                    tableStructInfo[5] = new CFieldInfo("fAppointmentHourIndex", "long", 0, 0, 1, "预约时间段索引", "预约时间段索引", "", 52, 0);
                    tableStructInfo[6] = new CFieldInfo("fAppointmentHours", "long", 0, 0, 1, "预约小时数", "预约小时数", "", 52, 0);
                    tableStructInfo[7] = new CFieldInfo("fAppointmentSubject", "text", 2, 0, 1, "预约科目", "预约科目", "", 52, 0);
                    tableStructInfo[8] = new CFieldInfo("fCoachGuid", "text", 36, 0, 1, "教练标识", "教练标识", "", 52, 0);
                    tableStructInfo[9] = new CFieldInfo("fCoachName", "text", 10, 0, 1, "教练姓名", "教练姓名", "", 52, 0);
                    tableStructInfo[10] = new CFieldInfo("fBookTime", "date", 0, 0, 1, "下单时间", "下单时间", "", 52, 0);
                    tableStructInfo[11] = new CFieldInfo("fBookChannel", "text", 20, 0, 1, "预约渠道", "预约渠道", "", 52, 0);
                    tableStructInfo[12] = new CFieldInfo("fStandardUnitPrice", "currency", 0, 0, 1, "标准单价", "标准单价", "", 52, 0);
                    tableStructInfo[13] = new CFieldInfo("fStandardAmount", "currency", 0, 0, 1, "标准总价", "标准总价", "", 52, 0);
                    tableStructInfo[14] = new CFieldInfo("fDiscountAmount", "currency", 0, 0, 1, "折扣价", "折扣价", "", 52, 0);
                    tableStructInfo[15] = new CFieldInfo("fReceivableAmount", "currency", 0, 0, 1, "应收款", "应收款", "", 52, 0);
                    break;
                case "TrnCourseSectionInfo":	 // 培训项目信息
                    tableStructInfo = new IFieldInfo[7];
                    tableStructInfo[0] = new CFieldInfo("fCourseGuid", "text", 36, 0, 0, "培训课程标识", "培训课程标识", "", 0, 0);
                    tableStructInfo[1] = new CFieldInfo("fSectionCode", "text", 0, 0, 0, "培训项目代码", "培训项目代码", "", 0, 0);
                    tableStructInfo[2] = new CFieldInfo("fSectionName", "text", 0, 0, 0, "培训项目名称，比如：通过人行横道、连续障碍", "培训项目名称，比如：通过人行横道、连续障碍", "", 0, 0);
                    tableStructInfo[3] = new CFieldInfo("fSectionStartTime", "date", 8, 0, 0, "开始时间", "开始时间", "", 0, 0);
                    tableStructInfo[4] = new CFieldInfo("fSectionEndTime", "date", 8, 0, 0, "结束时间", "结束时间", "", 0, 0);
                    tableStructInfo[5] = new CFieldInfo("fOperationScore", "long", 0, 0, 0, "操作得分", "操作得分", "", 0, 0);
                    tableStructInfo[6] = new CFieldInfo("fOperationResult", "text", 0, 0, 0, "操作结果[S:成功|F:失败]", "操作结果[S:成功|F:失败]", "", 0, 0);
                    break;
                default: tableStructInfo = null; break;
            }
            return tableStructInfo;
        }
        #endregion

        // AppointmentInfo
        public IDBDataObject GetAppointmentInfoData(string dataGuid)
        {
            //return this.GetUniqueData(TABLE_APPOINT_INFO, dataGuid);
            return this.DataLayer.GetDBDataObject(GetStructGlobalName(TABLE_APPOINT_INFO), string.Format("fAppointmentGuid = '{0}'", dataGuid));
        }

        //// NotesInfo
        //public IDBDataObject GetNotesInfoData(string strDataGuid)
        //{
        //    return this.GetUniqueData("NotesInfo", strDataGuid);
        //}

        //public IDBBigObjectSet GetNotesList(string SenderGuid)
        //{
        //    return DataLayer.GetDBBigObjectSet(GetStructGlobalName("NotesInfo"), string.Format("fSenderGuid = '{0}'", SenderGuid), "fCreateDate Desc");
        //}

        //// Receipt
        //public IDBDataObject GetReceiptData(string strDataGuid)
        //{
        //    return this.GetUniqueData("Receipt", strDataGuid);
        //}

        //public IDBDataObject GetReceiptData(string NotesGuid, string ReceiverGuid)
        //{
        //    IDBDataObject data = DataLayer.GetDBDataObject(GetStructGlobalName("Receipt"), string.Format("fReceiverGuid = '{0}' and fNotesGuid = '{1}'", ReceiverGuid, NotesGuid));
        //    if (data.ID == 0)
        //    {
        //        data["fGuid"] = Guid.NewGuid().ToString();
        //        data["fReceiverGuid"] = ReceiverGuid;
        //        data["fNotesGuid"] = NotesGuid;
        //    }
        //    return data;
        //}

        //public IDBBigObjectSet GetReceipts(string NotesGuid)
        //{
        //    return DataLayer.GetDBBigObjectSet(GetStructGlobalName("Receipt"), string.Format("fNotesGuid = '{0}'", NotesGuid), "fCreateDate Desc");
        //}
    }
}
